package org.yjw.demo.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.yjw.demo.bean.entity.user.User;

import java.util.List;

/**
 * @author 31898
 * 读取自定义配置的两种方案一种是@Value注解的方式，一种是通过指定properties文件的方式
 * @Component 将对象交给容器管理
 * PropertySource 指定properties文件的路径
 * ConfigurationProperties 指定key的前缀
 */
@Component
@PropertySource(value = "conf/custom.properties", encoding = "utf-8")
@ConfigurationProperties("student")
@Data
public class Student {

    /**
     * 取yml配置文件中的值
     */
    @Value("${server.port}")
    private String name2;
    private String name;
    private int age;
    private double score;
    private String[] cities;
//    private List<User> userList;


}
